package com.itheima.system.service.impl;


import com.itheima.system.dao.DeviceManageMapper;
import com.itheima.system.dao.DeviceMapper;
import com.itheima.system.pojo.Device;
import com.itheima.system.pojo.DeviceManage;
import com.itheima.system.service.DeviceManageService;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class DeviceManageServiceImpl implements DeviceManageService {

    @Autowired
    private DeviceManageMapper deviceManageMapper;

    @Autowired
    private DeviceMapper deviceMapper;
    /**
     * 查询所有
     * @return
     */
    @Override
    public List<DeviceManage> findAll() {
        return deviceManageMapper.selectAll();
    }

    /**
     * 添加
     * @param deviceManage
     */
    @Override
    public void add(DeviceManage deviceManage) {
        deviceManageMapper.insert(deviceManage);
    }

    /**
     * 修改
     * @param deviceManage
     */
    @Override
    public Integer update(DeviceManage deviceManage) {
        Integer i = deviceManageMapper.updateByPrimaryKey(deviceManage);
        return i;
    }

    /**
     * 根据ID查询
     * @param id
     * @return
     */
    @Override
    public List<DeviceManage> findById(Integer id) {
        Example example = new Example(DeviceManage.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("did",id);
        List<DeviceManage> deviceManageList = deviceManageMapper.selectByExample(example);
        return deviceManageList;
    }
}
